
close all;
sweep_plot=0

if sweep_plot==1

    %% sweep plot
    deadtime=[15];
    input_voltage=[80];
    load_current=[2];
    frequency=[200 400];

    figure;
    cc=hsv(length(deadtime)*length(input_voltage)*length(load_current)*length(frequency));
    marker={'x-'; 'o-';'^-';'*-'};
    legendInfo={};
    index=1;
    for i=1:length(deadtime)
        for j=1:length(input_voltage)
            for k=1:length(load_current)
                for u=1:length(frequency)
                    file=sprintf('./data/buck_deadtime/buck_%ikHz_%iV_%iA_deadtime_%i.dat',[frequency(u),input_voltage(j),load_current(k),deadtime(i)])
                    M = csvread(file,1,0);
                    Ploss=M(:,5)-M(:,6);
                    Iout=M(:,4);
                    plot(Iout.^2,Ploss,marker{index},'color',cc(index,:),'LineWidth',0.75);
                    hold all;
                    legendInfo{index} = sprintf('%ikHz %iV %iA deadtime %i',[frequency(u),input_voltage(j),load_current(k),deadtime(i)]);
                    index=index+1;
                end
            end
        end
    end


    %%
    xlabel('Load current (A)');
    ylabel('Power loss (W)');
    legend(legendInfo,'Location','SouthEast');
    grid on;
    % ylim([65 100]);
    % xlim([0 410]);

    set(gcf, 'Position', [200 200 450 300])
    set(gcf,'PaperPositionMode','auto')
    % print('-depsc2', '../Paper/images/efficiency_unregulated_exp');
    % matlab2tikz( '../Paper/images/efficiency_unregulated_exp.tikz',  'height', '\figureheight', 'width', '\figurewidth','showInfo', false);


else

    %% pick plot
    
    frequency_voltage_current_deadtime_Rg=[ 200 40 1 10 0; ...
                                            200 40 1 10 2;
                                            ];

   [number_of_plots ~]=size(frequency_voltage_current_deadtime);
    figure;
    cc=hsv(number_of_plots);
    marker={'x-'; 'o-';'^-';'*-';'s-'};
    legendInfo={};

    for i=1:number_of_plots
        file=sprintf('./data/buck_deadtime/buck2_%ikHz_%iV_%iA_deadtime_%i_%iohms.dat',frequency_voltage_current_deadtime_Rg(i,:))
        M = csvread(file,1,0);
        Ploss=M(:,5)-M(:,6);
        Iout=M(:,4);
        plot(Iout,Ploss,marker{i},'color',cc(i,:),'LineWidth',0.75);
        hold all;
        legendInfo{i} = sprintf('%ikHz %iV %iA deadtime %i %i Ohms',frequency_voltage_current_deadtime_Rg(i,:));
    end


    %%
    xlabel('Load current (A)');
    ylabel('Power loss (W)');
    legend(legendInfo,'Location','SouthEast');
    grid on;
    % ylim([65 100]);
    % xlim([0 410]);

    set(gcf, 'Position', [200 200 450 300])
    set(gcf,'PaperPositionMode','auto')
    % print('-depsc2', '../Paper/images/efficiency_unregulated_exp');
    % matlab2tikz( '../Paper/images/efficiency_unregulated_exp.tikz',  'height', '\figureheight', 'width', '\figurewidth','showInfo', false);
end